# Makefile for DigitalMars C.

# Header files for the pryn library.
headers = \
	Include\pryn.h \
	Include\pryn\change.h \
 Include\pryn\common.h \
	Include\pryn\component.h \
 Include\pryn\cpp.h \
	Include\pryn\factory.h \
	Include\pryn\library.h \
	Include\pryn\mediator.h \
	Include\pryn\monitor.h \
	Include\pryn\object.h \
	Include\pryn\pin.h \
 Include\pryn\platform.h \
	Include\pryn\result.h \
	Include\pryn\state.h \
	Include\pryn\string.h \
	Include\pryn\tag.h \
	Include\pryn\type.h \
	Include\pryn\utility.h \
	Include\pryn\value.h \
	Include\pryn\vector.h

# Platform-neutral source files for the pryn library.
sourcesGeneric = \
	Source\component.c \
	Source\factory.c \
	Source\library.c \
	Source\mediator.c \
	Source\monitor.c \
	Source\object.c \
	Source\pin.c \
	Source\print.c \
	Source\state.c \
	Source\string.c \
	Source\tag.c \
	Source\type.c \
	Source\utility.c \
	Source\value.c
	
# Pryn-library source files for the Windows platform.
sourcesWindows = \
	Source\Platforms\Windows\dllmain.c \
	Source\Platforms\Windows\fileIteration.c \
	Source\Platforms\Windows\memory.c \
	Source\Platforms\Windows\windowsLibrary.c \
	Source\Platforms\Windows\windowsState.c

# Header files for the prynGui library.
headersGui = \
	Include\prynGui.h \
	Include\pryn\gui\control.h \
 Include\pryn\gui\cpp.h \
 Include\pryn\gui\event.h \
	Include\pryn\gui\menu.h \
	Include\pryn\gui\painter.h
	
# Platform-neutral source files for the prynGui library.
sourcesGuiGeneric = \
	Source\Gui\event.c \
	Source\Gui\menu.c \
	Source\Gui\control.c \
	Source\Gui\painter.c
	
# Windows-specific source files for the prynGui library.
sourcesGuiWindows = \
	Source\Gui\Platforms\Windows\windowsControl.c \
	Source\Gui\Platforms\Windows\windowsMenu.c  \
	Source\Gui\Platforms\Windows\windowsPainter.c
	
# Windows-specific internal header files for the prynGui library.
headersGuiInternalWindows = \
	Source\Gui\Platforms\Windows\platform.h

# Header files for the prynEditor library.
headersEditor = \
	Include\prynEditor.h \
	Include\pryn\editor\board.h \
	Include\pryn\editor\component.h \
	Include\pryn\editor\path.h \
	Include\pryn\editor\pin.h
	
# Platform-neutral source files for the prynEditor library.
sourcesEditorGeneric = Source\Editor\board.c Source\Editor\component.c Source\Editor\editor.c Source\Editor\path.c Source\Editor\pin.c

# Windows-specific source files for the prynEditor library.
sourcesEditorWindows =

# Merge source file lists for the current platform.
sources = $(sourcesGeneric) $(sourcesWindows)
sourcesEditor = $(sourcesEditorGeneric) $(sourcesEditorWindows)
sourcesGui = $(sourcesGuiGeneric) $(sourcesGuiWindows)

Build = c:\dm\bin\sc -w7 -IInclude -r kernel32.lib user32.lib gdi32.lib -6 -o
BuildLibrary = $(Build) -WD pryn.lib
BuildResource = rc.exe /r

# Mixin to a build command needed for C++.
CPP = -Ae

all: pryn.dll prynEditor.dll prynGui.dll libraries Makefile Libraries\logic.dll
 $(Build) $(CPP) Source\main.cpp pryn.exe pryn.lib Source\Platforms\Windows\pryn.res prynEditor.lib prynGui.lib
	@del *.map
	@del *.def
	@del Libraries\*.def
	@del *.obj
	pryn
	
Source\Platforms\Windows\pryn.res: Makefile Source\Platforms\Windows\pryn.rc Source\Platforms\Windows\pryn.exe.manifest Source\strings.h
	$(BuildResource) Source\Platforms\Windows\pryn.rc
	
prynGui.dll: pryn.dll $(sourcesGui) $(headersGui) Makefile $(headersGuiWindows)
	$(BuildLibrary) $(sourcesGui) $@ -NL -DPrynGuiInternal -DPrynGuiImplementation
	implib prynGui.lib prynGui.dll
	
prynEditor.dll: pryn.dll prynGui.dll $(sourcesEditor) $(headersEditor) Makefile
	$(BuildLibrary) $(sourcesEditor) $@ prynGui.lib -NL -DPrynEditorImplementation
	implib prynEditor.lib prynEditor.dll
	
libraries: Libraries\logic.dll
#Libraries\image.dll Libraries\photoshop.dll Libraries\winamp.dll Libraries\totalCommander.dll Libraries\inputOutput.dll
	
Libraries\logic.dll: pryn.dll Source\Libraries\logic.cpp Makefile
 $(BuildLibrary) $(CPP) Source\Libraries\logic.cpp Libraries\logic.dll
	
Libraries\image.dll: pryn.dll Source\Libraries\image.c Makefile
	$(BuildLibrary) Source\Libraries\image.c $@

Libraries\photoshop.dll: pryn.dll Source\Libraries\photoshop.c Libraries\Photoshop\plugin.dll Makefile Source\Libraries\photoshop.h
	$(BuildLibrary) Source\Libraries\photoshop.c $@ -NL
	
Libraries\Photoshop\plugin.dll: pryn.dll Source\Libraries\Photoshop\plugin.c Makefile Source\Libraries\photoshop.h
	$(BuildLibrary) Source\Libraries\Photoshop\plugin.c $@ -NL

Libraries\winamp.dll: pryn.dll Source\Libraries\winamp.cpp Makefile Source\Libraries\winamp.h
	$(BuildLibrary) Source\Libraries\winamp.cpp $@ -NL
	
Libraries\totalCommander.dll: pryn.dll Source\Libraries\totalCommander.c Makefile Source\Libraries\totalCommander.h
	$(BuildLibrary) Source\Libraries\totalCommander.c $@
	
Libraries\inputOutput.dll: pryn.dll Source\Libraries\inputOutput.c Makefile Include\pryn\types\file.h
	$(BuildLibrary) Source\Libraries\inputOutput.c $@
	
Libraries\archive.dll: pryn.dll Source\Libraries\archive.c Makefile Include\pryn\types\archive.h
	$(BuildLibrary) Source\Libraries\archive.c $@
	
pryn.lib: pryn.dll
	
pryn.dll: $(sources) $(headers) Makefile Source\Platforms\Windows\pryn.res
	$(Build) $(sources) pryn.dll -WD kernel32.lib -NL Source\Platforms\Windows\pryn.res -DPrynInternal -DPrynImplementation
	implib pryn.lib pryn.dll
	
